<?php

namespace Trawind\Extension\Models\Custom;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Prettus\Repository\Contracts\Transformable;
use Prettus\Repository\Traits\TransformableTrait;
use Trawind\Basics\Enums\BusinessType;
use Trawind\Extension\Traits\CustomData;

/**
 * Class Field.
 *
 * @package namespace Trawind\Extension\Models\Custom;
 */
class Field extends Model implements Transformable
{

    use TransformableTrait, CustomData;

    const ORIGIN_TYPE_ENUM = [
        'system_field' => 1,
        'custom_field' => 2
    ];

    const VISIBILITY_TYPE_ENUM = [
        'read_and_write' => 1,
        'read_only' => 2,
        'hide' => 3
    ];

    const WIDGET_TYPE_ENUM = [
        'field_widget_input' => 1,
        'field_widget_text' => 2,
        'field_widget_switch' => 3,
        'field_widget_enmus' => 4,
        'field_widget_relation' => 5,
        'field_widget_date_time' => 6,
        'field_widget_tree_relation' => 7,
        'field_widget_auto_number' => 8,
        'field_widget_upload_img' => 9,
        'field_widget_upload_file' => 10,
    ];

    protected $table = 'custom_fields';

    protected $connection = 'mysql';

    protected $dateFormat = 'U';

    public $incrementing = false;

    protected $guarded = ['created_at', 'updated_at'];

    public $businessType = BusinessType::EXTENSION_CUSTOM_FIELD;

}
